package com.itheima.config;

import com.itheima.interceptor.Inteceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*
*
 * @Author：cxl
 * @Package：com.itheima.config
 * @Project：web-project
 * @name：WebConfig
 * @Date：2025-09-30 4:39 pm
 * @Filename：WebConfig
*/



//配置类，也是创建容器，和Controller那些很像
//定义哪些对象由容器来创建，要配合@Bean注解
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private Inteceptor inteceptor;

    //注册（配置）拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加拦截器
        registry.addInterceptor(inteceptor)
                //拦截所有
                .addPathPatterns("/**")
                //排除路径，白名单
                .addPathPatterns("/login");
    }
}
